<template style="margin:auto;padding: auto;">
  <div class="ddi">
    <a-layout>
      <a-layout-content>
        <div class="dd2 warp" style="width: 67%;margin-right: 1%;">
          <TasksForm1></TasksForm1>
        </div>
        <div class="dd1 warp" style="width: 32%;">
          <ReadForm></ReadForm>
        </div>
      </a-layout-content>
      <template>
        <inform/>
      </template>
    </a-layout>
  </div>
</template>
<script>
  import Vue from 'vue'
  import { mapActions,mapGetters } from 'vuex'
  import TasksForm1 from '@/views/dashboard/TasksForm1'
  import ReadForm from '@/views/dashboard/ReadForm'
  import { USER_INFO,ACCESS_TOKEN,ACCESS_TOKEN_IP } from '@/store/mutation-types'
  import { openIFrame } from '@/utils/util'
  import Inform from '@/views/dashboard/Inform'

  export default {
    name: 'Analysis',
    components: {
      TasksForm1,
      ReadForm,
      Inform
    },
    data() {
      return {
        notices: []
      }
    },
    mounted() {
      if(!this.isFlashHome()) {
        this.initData();
        this.setIsFlashHome(true)
      }
    },
    methods: {
      ...mapActions(['setIsFlashHome']),
      ...mapGetters(["isFlashHome"]),
      showDetail(item) {
        let baseUrl = process.env.VUE_APP_ADD_HTTP
        let ticket = Vue.ls.get(ACCESS_TOKEN)
        let UserIP = "&UserIP="+ Vue.ls.get(ACCESS_TOKEN_IP);
        let url = baseUrl + "/login.xip?LoginMethod=ssologin&Ticket=" + ticket + UserIP + "&ReturnUrl="+ encodeURIComponent(item.Url)
        openIFrame(item.Bi_Code, '/Messages/' + item.Bi_Code, item.msgtitle, url)
        this.$router.push({ name: item.Bi_Code })
        //关闭弹框
        this.$notification.close(item.bfm_id)
        //修改状态
        let params = {
            id : item.bfm_id
        }
        this.getRequest('/common/UpdateFlowMessageInfo', params)
          .then(res => {

          })
      },
      openNoti() {
        for(let i=0;i<this.notices.length;i++){
          let notice = this.notices[i];
          let that = this
          setTimeout(function () {
            that.$notification.open({
              message: (h) => {
                return h('span', {
                  style: {
                    fontSize: '18px',
                    fontWeight: 'bold'
                  }
                }, '消息')
              },
              description: (h) => {
                  return h('li', {
                    style: {
                      margin: '2px'
                    }
                  }, [
                    h('a', {
                      on: {
                        click: () => that.showDetail(notice)
                      },
                    }, [h('span', notice.msg.replace('||', '').replace('||', ''))])
                  ])
              },
              onClose: () => that.$notification.close(),
              duration: 0,
              placement: 'bottomRight',
              key: notice.bfm_id
            })
          },100)
        }
      },
      initData() {
        let _this = this
        let userInfo = Vue.ls.get(USER_INFO)
        let params = {
          userid: userInfo.Ur_ID
        }
        this.getRequest('/common/GetFlowMessageList', params)
          .then(res => {
            _this.notices = res
            _this.openNoti()
          })
      }
    }
  }
</script>
<style lang="scss" scoped>
  .warp {
    margin-top: 2px;
    position: relative;
    overflow: hidden;
  }

  #form,
  #form1,
  #form4,
  .dd2,
  .dd1 {
    float: left;
  }

  .ddi {
    margin: auto !important;
    padding: auto !important;
  }

  .right_fbox {
    width: 143px;
    height: 349px;
    position: fixed;
    float: right;
    left: 52%;
    top: 40%;
    z-index: 999;
    margin-left: 630px;
  }
</style>